package com.xyrl.project.common.news.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xyrl.project.common.constant.XyrlConstant;
import com.xyrl.project.common.news.dao.NewsMapper;
import com.xyrl.project.common.news.entity.News;
import com.xyrl.project.common.news.enums.NewtTypeEnum;
import com.xyrl.project.common.news.service.NewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @className NewsServiceImpl.java
 * @company 重庆星纭融链科技公司
 * @author 徐恩源
 * @version 1.0
 * @date 2019-12-26 10:40:07
 * @Description 新闻资讯service
 */
@Slf4j
@Service("newsServiceImpl")
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {


    @Override
    public News queryNewsByType(NewtTypeEnum newtTypeEnum) {
        LambdaQueryWrapper<News> lambdaQuery = Wrappers.lambdaQuery();
        lambdaQuery.eq(News::getNewType, newtTypeEnum.name());
        lambdaQuery.eq(News::getEnableFlag, XyrlConstant.YES);
        return super.getOne(lambdaQuery);
    }
}

